{% extends "cmdb/mequipment/index.html" %}

{% block right_content %}
<div id="right_menu">
    <b class="modal-title">维修信息编辑</b>
    <hr/>
    <form class="form-horizontal">
        <div class="form-inline" style="padding-left:39px">
            <label for="id">编号</label>
            <input class="form-control" style="width:400px;" type="text" id="id" value="{{ equipment_maint_log.id }}" disabled/>
        </div><br />
        <div class="form-inline">
            <label for="serialNum">设备序列号</label>
            <input class="form-control" style="width:400px;" type="text" id="serialNum" value="{{ equipment_maint_log.serial_num }}" disabled/>
        </div><br />
        <div class="form-inline" style="padding-left:12px">
            <label for="maintTime" style="vertical-align: top;">报修日期</label>
            <input class="form-control" style="width:400px;" type="text" id="maintTime" value="{{ equipment_maint_log.maint_time }}" readonly />
            <span style="display:none;">*必填</span>
        </div><br />
        <div class="form-inline" style="padding-left:27px">
            <label for="maintMan">报修人</label>
            <input class="form-control" style="width:400px;" type="text" id="maintMan" value="{{ equipment_maint_log.maint_man }}" />
            <span style="display:none;">*必填</span>
        </div><br />
        <div class="form-inline" style="padding-left:12px">
            <label for="problem">故障现象</label>
            <textarea rows="4" id="problem" class="form-control" style="width:400px;">{{ equipment_maint_log.problem }}</textarea>
            <span style="display:none;">*必填</span>
        </div><br />
        <div class="form-inline" style="padding-left:12px">
            <label for="repairTime">修复日期</label>
            <input class="form-control" style="width:400px;" type="text" id="repairTime" value="{{ equipment_maint_log.repair_time }}" readonly/>
            <span style="display:none;">*必填</span>
        </div><br />
        <div class="form-inline" style="padding-left:27px">
            <label for="present">到场人</label>
            <input class="form-control" style="width:400px;" type="text" id="present" value="{{ equipment_maint_log.present }}" />
            <span style="display:none;">*必填</span>
        </div><br />
        <div class="form-inline" style="padding-left:27px">
            <label for="pepairMan">维修人</label>
            <input class="form-control" style="width:400px;" type="text" id="pepairMan" value="{{ equipment_maint_log.pepair_man }}" />
            <span style="display:none;">*必填</span>
        </div><br />
        <div class="form-inline" style="padding-left:12px">
            <label for="resolution">解决方法</label>
            <textarea rows="4" id="resolution" class="form-control" style="width:400px;">{{ equipment_maint_log.resolution }}</textarea>
            <span style="display:none;">*必填</span>
        </div><br />
        <div class="form-inline" style="padding-left:39px">
            <label for="comment">备注</label>
            <input class="form-control" style="width:400px;" type="text" id="comment" value="{{ equipment_maint_log.comment }}" />
            <span style="display:none;">*必填</span>
        </div><br />
        <input type="text" id="operator" value="{{ request.session.username }}" style="display: none;">
    </form>
    <div style="padding-left: 100px;">
        <button type="button" class="btn btn-primary" id="item_edit">
            确定
        </button>&nbsp;&nbsp;&nbsp;
        <button type="button" class="btn btn-default" id="edit_cancel">
            取消
        </button>
    </div>
</div>

<script type="text/javascript">
var myDate1 = new Calender({id:'repairTime',isSelect:!0});
var myDate2 = new Calender({id:'maintTime',isSelect:!0});
$("#item_edit").click(function(){
    var id = $("#id").val();
    var problem = $("#problem").val();
    var maint_time = $("#maintTime").val();
    var maint_man = $("#maintMan").val();
    var repair_time = $("#repairTime").val();
    var present = $("#present").val();
    var pepair_man = $("#pepairMan").val();
    var resolution = $("#resolution").val();
    var comment = $("#comment").val();
    var operator = $("#operator").val();
    var urls = "{% url 'equipment:reditaction' %}";
    var postdata = {id:id, problem:problem, maint_time:maint_time,maint_man:maint_man,repair_time:repair_time,
                    present:present,pepair_man:pepair_man,resolution:resolution,comment:comment,operator:operator}
    var jsonstr = $.ajax({
			url : urls,
			type : "POST",
			data : postdata,
			async : false,
			cache : false
		});
		var jsonobj = eval('(' + jsonstr.responseText + ')');
		if(jsonobj.status==0){
		    alert(jsonobj.message);
		}else{
            window.location.href="{% url 'equipment:repairinfo' %}?page=" + {{ page }};
        }
});

$("#edit_cancel").click(function(){
    window.location.href="{% url 'equipment:repairinfo' %}?page=" + {{ page }};
});
</script>
{% endblock %}